<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"/>
    <title th:text="#{label.badUser.title}">bad user</title>
</head>
<body>
<div class="container">
<h1 class="alert alert-danger" th:text="${param.message[0]}">error</h1>
<br/>
<a class="btn btn-default" th:href="@{/registration.html}" th:text="#{label.form.loginSignUp}">signup</a>

<div th:if="${param.expired[0]}">
<br/>
<h1 th:text="#{label.form.resendRegistrationToken}">resend</h1>
<button onclick="resendToken()">resend</button>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script th:inline="javascript">
var serverContext = [[@{/}]];

function resendToken(){
	var token = [[${param.token}]];
    $.get(serverContext + "user/resendRegistrationToken?token="+token, function(data){
        window.location.href = serverContext +"login?message=" + data.message;
    })
    .fail(function(data) {
        if(data.responseJSON.error.indexOf("MailError") > -1)
        {
            window.location.href = serverContext + "emailError.html";
        }
        else{
            window.location.href = serverContext + "login?message=" + data.responseJSON.message;
        }
    });
}

$(document).ajaxStart(function() {
    $("title").html("LOADING ...");
});
</script>

</div>
</div>
</body>
</html>
